-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
🤖 Beep boop! Screenshot test report 🚦1 screenshot changed from Details1 Changed: |
Codecov Report
@@ Coverage Diff @@
## master #3310 +/- ##
=========================================
Coverage ? 98.06%
=========================================
Files ? 120
Lines ? 5155
Branches ? 644
=========================================
Hits ? 5055
Misses ? 100
Partials ? 0
Continue to review full report at Codecov.
|
🤖 Beep boop! Screenshot test report 🚦1 screenshot changed from Details1 Changed: |
🤖 Beep boop! Screenshot test report 🚦1 screenshot changed from Details1 Changed: |
demos/card.html
Outdated
data-toggle-off-content="favorite_border" | ||
data-toggle-off-label="Add to favorites">favorite_border</button> | ||
title="Add to favorites" data-demo-toggle> | ||
<i class="material-icons mdc-icon-button__icon" data-toggle-on>favorite</i> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we need to select on this data attribute in CSS, it might make sense to make it a class instead (e.g. mdc-icon-button__icon--on
?) - attribute selectors perform a lot slower in IE and Edge.
packages/mdc-icon-button/README.md
Outdated
Note the use of `data-toggle-on` attribute in the above examples. This attribute indicates which element is the | ||
on element. When the `mdc-icon-button--on` class is present, the element with the `data-toggle-on` attribute | ||
will be shown and the other element will be hidden. When the `mdc-icon-button--on` class is not present, the element | ||
with the `data-toggle-on` attribute will be hidden and the other element will beshown. This is what allows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beshown -> be shown
packages/mdc-icon-button/README.md
Outdated
on element. When the `mdc-icon-button--on` class is present, the element with the `data-toggle-on` attribute | ||
will be shown and the other element will be hidden. When the `mdc-icon-button--on` class is not present, the element | ||
with the `data-toggle-on` attribute will be hidden and the other element will beshown. This is what allows | ||
MDCIconButtonToggle to be so flexible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This is what allows MDCIconButtonToggle to be so flexible." -> "This structure allows MDCIconButton to be flexible enough to support both icon fonts and images/SVGs."
packages/mdc-icon-button/README.md
Outdated
@@ -140,6 +157,7 @@ cannot be disabled. Disabled icon buttons cannot be interacted with and have no | |||
CSS Class | Description | |||
--- | --- | |||
`mdc-icon-button` | Mandatory. | |||
`mdc-icon-button--on` | Used to indicate the toggle button icon that is the not-selected option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't sound right... This class is applied to the root element when the toggle should be in the "on" state, right?
packages/mdc-icon-button/README.md
Outdated
`addClass(className: string) => void` | Adds a class to the root element, or the inner icon element. | ||
`removeClass(className: string) => void` | Removes a class from the root element, or the inner icon element. | ||
`setText(text: string) => void` | Sets the text content of the root element, or the inner icon element. | ||
`addClass(className: string) => void` | Adds a class to a icon element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were these docs changed? Doesn't this still apply to the root element?
if (label) { | ||
this.adapter_.setAttr(ARIA_LABEL, label); | ||
} | ||
this.adapter_.setAttr(strings.ARIA_PRESSED, `${this.isOn()}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.isOn()
-> isOn
?
if (classToRemove) { | ||
this.adapter_.removeClass(classToRemove); | ||
this.on_ = isOn; | ||
if (this.isOn()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.isOn()
-> isOn
? We already have the variable right here.
@@ -157,7 +157,7 @@ | |||
"screenshots": { | |||
"desktop_windows_chrome@latest": "https://storage.googleapis.com/mdc-web-screenshot-tests/advorak/2018/07/31/04_55_54_478/spec/mdc-card/classes/baseline.html.windows_chrome_67.png", | |||
"desktop_windows_edge@latest": "https://storage.googleapis.com/mdc-web-screenshot-tests/advorak/2018/07/31/04_55_54_478/spec/mdc-card/classes/baseline.html.windows_edge_17.png", | |||
"desktop_windows_firefox@latest": "https://storage.googleapis.com/mdc-web-screenshot-tests/advorak/2018/07/31/04_55_54_478/spec/mdc-card/classes/baseline.html.windows_firefox_61.png", | |||
"desktop_windows_firefox@latest": "https://storage.googleapis.com/mdc-web-screenshot-tests/travis/2018/08/07/22_51_57_136/spec/mdc-card/classes/baseline.html.windows_firefox_61.png", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems weird...is this diff consistent, and if so do we have any possible explanation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's consistent. This was a result of me accepting screenshot diffs from master, not from within this branch.
@@ -22,6 +22,7 @@ import {verifyDefaultAdapter} from '../helpers/foundation'; | |||
import MDCIconButtonToggleFoundation from '../../../packages/mdc-icon-button/foundation'; | |||
|
|||
const {strings} = MDCIconButtonToggleFoundation; | |||
const {cssClasses} = MDCIconButtonToggleFoundation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change above line to const {cssClasses, strings} = ...
and you don't need this line
}); | ||
|
||
test('#adapter.addClass adds a class to the inner icon element when used', () => { | ||
const {root, component} = setupTest({useInnerIconElement: true}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We seem to never use useInnerIconElement
or tabIndex
in setupTest
anymore.
Are we losing anything by no longer supporting the inner icon element? I'm inclined to think that's mitigated by having separate DOM for each state now.
🤖 Beep boop! Screenshot test report 🚦5 screenshots changed from Details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't seem to have a foundation test for the isOn
method.
DATA_TOGGLE_OFF_LABEL: 'data-toggle-off-label', | ||
DATA_TOGGLE_OFF_CONTENT: 'data-toggle-off-content', | ||
DATA_TOGGLE_OFF_CLASS: 'data-toggle-off-class', | ||
DATA_TOGGLE_ON_ATTR: 'data-toggle-on', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer used since it's now a class
@@ -18,16 +18,12 @@ | |||
/** @enum {string} */ | |||
const cssClasses = { | |||
ROOT: 'mdc-icon-button', | |||
ICON_BUTTON_ON_CLASS: 'mdc-icon-button--on', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_CLASS
seems redundant within the cssClasses
hash... we could potentially even shorten this to just ON
since it's a modifier class for the root element?
.mdc-icon-button__icon { | ||
display: inline-block; | ||
|
||
// stylelint-disable-next-line plugin/selector-bem-pattern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leaving a note here for posterity, that although this needs to do things that aren't entirely in line with BEM, we're significantly simplifying the JS implementation (including adapter) by toggling a single class on the root rather than needing to add a class to one child and remove it from the other every time the icon button is toggled.
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Baseline Icon Button - MDC Web Screenshot Test</title> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add "Toggle" to this title
🤖 Beep boop! Screenshot test report 🚦5 screenshots changed from Details |
fixes: #3277 , resolves #3154, resolves #3107
BREAKING CHANGE: Removes the previous
data
attributes and no longer dynamically changes the label. Allows developers to add both elements to the button, with one indicated as theon
state by using adata-toggle-on
attribute. State is now changed by adding/removing themdc-icon-button--on
class to themdc-icon-button
element. All icon elements should have themdc-icon-button__icon
class.